﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Xml.Linq;

namespace LastFmClient
{
    public class SimilarTrack
    {


//<track>
//−
    //<artist>
        //<name>Iron Maiden</name>
        //<url>http://www.last.fm/music/Iron+Maiden</url>
    //</artist>
//<name>Run to the Hills</name>
//<match>24.84</match>
//−
//<url>
//http://www.last.fm/music/Iron+Maiden/_/Run+to+the+Hills
//</url>
//<streamable>1</streamable>
//</track>

        public SimilarTrack(XElement x)
        {
            XElement = x;
        }

        private XElement XElement { get; set; }

        public string ArtistName
        {
            get
            {
                return XElement.Element("artist").Element("name").Value;
            }
        }

        public string Name
        {
            get
            {
                return XElement.Element("name").Value;
            }
        }

        public double Match
        {
            get
            {
                return Convert.ToDouble(XElement.Element("match").Value);
            }
        }

        public string Url
        {
            get
            {
                return XElement.Element("url").Value;
            }
        }

        public bool Streamable
        {
            get
            {
                return Convert.ToInt32(XElement.Element("streamable").Value) == 1;
            }
        }

        private Artist m_ArtistObject;
        public Artist Artist
        {
            get
            {
                if (m_ArtistObject == null)
                    m_ArtistObject = new Artist(this.ArtistName);

                return m_ArtistObject;
            }
        }

        private Track m_TrackObject;
        public Track Track
        {
            get
            {
                if (m_TrackObject == null)
                    m_TrackObject = new Track(this.Name, this.ArtistName);

                return m_TrackObject;
            }
        }
    }
}
